/**
 * @format
 * @Author: TC
 * @Date: 2025-07-28 16:50:21
 * @Last Modified by: TC (tengchao@taqu.cn)
 * @Last Modified time: 2025-10-21 16:58:02
 */

import { _decorator, Component, easing, Node, tween, v3 } from "cc";
import { app } from "db://assets/FrameWork/App";
import { BaseUI } from "db://assets/FrameWork/Module/Component/BaseUI";
import { EMoleUIConst } from "../../Const/MoleUIConst";
import { gameMole } from "../../GameMole";
const { ccclass, property } = _decorator;

/**
 * 主界面
 */
@ccclass("MoleMainUI")
export class MoleMainUI extends BaseUI {
    @property({ type: Node, displayName: "开始按钮" })
    private btnStart: Node = null;

    protected init(): void {
        super.init();
        gameMole.bagMgr.init();
        this._playStartAni();
    }

    protected addUIEvent(): void {
        super.addUIEvent();
        this.addClickEvent(this.btnStart, this._onStart);
    }

    private _playStartAni(): void {
        tween(this.btnStart)
            .to(0.25, { scale: v3(1.2, 0.8, 1) })
            .to(0.15, { scale: v3(1, 1, 1) })
            .by(0.25, { position: v3(0, 50, 0) })
            .by(0.25, { position: v3(0, -50, 0) })
            .union()
            .repeatForever()
            .start();
    }

    /**
     * 点击开始
     */
    private _onStart(): void {
        app.uiMgr.openUI(EMoleUIConst.PrepareUI);
    }
}
